/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Master_Penjadwalan.java
 *
 * Created on Nov 19, 2012, 4:17:25 PM
 */
package rploo_ciayoo;

import Dosen.Dosen;
import Dosen.DosenKontrol;
import Matakuliah.MakulKontrol;
import Matakuliah.Matakuliah;
import Penjadwalan.JadwalKontrol;
import Penjadwalan.Penjadwalan;
import Penjadwalan.PenjadwalanTabelModel;
import Ruang.Ruang;
import Ruang.RuangKontrol;
import java.sql.SQLException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.print.DocFlavor.STRING;
import javax.swing.JOptionPane;
import rploo_ciayoo.kontrol.KoneksiDatabase;

/**
 *
 * @author Yulius
 */
public class Master_Penjadwalan extends javax.swing.JInternalFrame {

    /**
     * Creates new form Master_Penjadwalan
     */
    public Master_Penjadwalan() {

        initComponents();
//        lihatSemua();
        comboDosen();
        comboMatakuliah();
        comboRuang();
        tampilSemua();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        HariCmbx = new javax.swing.JComboBox();
        idDosenCmbx = new javax.swing.JComboBox();
        idRuangCmbx = new javax.swing.JComboBox();
        kodeMakulCmbx = new javax.swing.JComboBox();
        jamCmbx = new javax.swing.JComboBox();
        simpanBtn = new javax.swing.JButton();
        hapusBtn = new javax.swing.JButton();
        keluarBtn = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jScrollPane5 = new javax.swing.JScrollPane();
        tabelJadwal = new javax.swing.JTable();
        updateBtn = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        kelasCmbx = new javax.swing.JComboBox();

        HariCmbx.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Senin", "Selasa", "Rabu", "Kamis", "Jumat" }));
        HariCmbx.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                HariCmbxActionPerformed(evt);
            }
        });

        idDosenCmbx.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                idDosenCmbxActionPerformed(evt);
            }
        });

        idRuangCmbx.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                idRuangCmbxActionPerformed(evt);
            }
        });

        jamCmbx.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "07.00 - 08.00", "08.00 - 09.00", "09.00 - 10.00", "10.00 - 11.00", "11.00 - 12.00", "12.00 - 13.00", "13.00 - 14.00", "14.00 - 15.00", "15.00 - 16.00", "16.00 - 17.00" }));
        jamCmbx.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jamCmbxActionPerformed(evt);
            }
        });

        simpanBtn.setText("Simpan");
        simpanBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                simpanBtnActionPerformed(evt);
            }
        });

        hapusBtn.setText("Hapus");
        hapusBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                hapusBtnActionPerformed(evt);
            }
        });

        keluarBtn.setText("Keluar");
        keluarBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keluarBtnActionPerformed(evt);
            }
        });

        jLabel6.setText("Hari");

        jLabel7.setText("Kode Makul");

        jLabel8.setText("Id Dosen");

        jLabel9.setText("Jam");

        jLabel10.setText("Id Ruang");

        tabelJadwal.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null}
            },
            new String [] {
                "Hari", "Jam", "Kelas", "Id Matakuliah", "Id Dosen", "Id Ruang"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                true, true, true, true, false, true
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tabelJadwal.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tabelJadwalMouseClicked(evt);
            }
        });
        jScrollPane5.setViewportView(tabelJadwal);

        updateBtn.setText("Update");
        updateBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                updateBtnActionPerformed(evt);
            }
        });

        jLabel1.setText("Kelas");

        kelasCmbx.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "A", "B", "C", "D" }));
        kelasCmbx.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                kelasCmbxActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(simpanBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(updateBtn)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(hapusBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 449, Short.MAX_VALUE)
                        .addComponent(keluarBtn)
                        .addGap(57, 57, 57))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel7)
                                    .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel10))
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(HariCmbx, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(kodeMakulCmbx, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(idRuangCmbx, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGap(42, 42, 42)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel8)
                                            .addComponent(jLabel9))
                                        .addGap(32, 32, 32)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(idDosenCmbx, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGroup(layout.createSequentialGroup()
                                                .addComponent(jamCmbx, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(31, 31, 31)
                                                .addComponent(jLabel1)
                                                .addGap(18, 18, 18)
                                                .addComponent(kelasCmbx, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE))))))
                            .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 789, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(28, Short.MAX_VALUE))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(16, 16, 16)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(HariCmbx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(24, 24, 24)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(kodeMakulCmbx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(idDosenCmbx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(idRuangCmbx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9)
                    .addComponent(jamCmbx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1)
                    .addComponent(kelasCmbx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(38, 38, 38)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(simpanBtn)
                    .addComponent(hapusBtn)
                    .addComponent(updateBtn)
                    .addComponent(keluarBtn))
                .addContainerGap(79, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void HariCmbxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_HariCmbxActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_HariCmbxActionPerformed

    private void keluarBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keluarBtnActionPerformed
        this.dispose();
}//GEN-LAST:event_keluarBtnActionPerformed

    private void jamCmbxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jamCmbxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jamCmbxActionPerformed

    private void idDosenCmbxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_idDosenCmbxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_idDosenCmbxActionPerformed

    private void idRuangCmbxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_idRuangCmbxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_idRuangCmbxActionPerformed

    private void kelasCmbxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_kelasCmbxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_kelasCmbxActionPerformed

    private void simpanBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_simpanBtnActionPerformed
        // TODO add your handling code here:
        Penjadwalan jadwal = new Penjadwalan();

        String hari = (String) HariCmbx.getSelectedItem();

        int k = kodeMakulCmbx.getSelectedIndex();
        String kode = kodeMakulCmbx.getItemAt(k).toString();
        int d = idDosenCmbx.getSelectedIndex();
        String dosen = idDosenCmbx.getItemAt(d).toString();
        int r = idRuangCmbx.getSelectedIndex();
        String ruang = (String) idRuangCmbx.getSelectedItem();
        System.out.println(ruang);
        String jam = (String) jamCmbx.getSelectedItem();
        String kelas = (String) kelasCmbx.getSelectedItem();

        jadwal.setHari(hari);

        String[] tampung2 = kode.split(" ");
        System.out.println(tampung2[0]);
        Matakuliah matkul = new Matakuliah();
        matkul.setIdMatakuliah(tampung2[0]);
//        matkul.setNamaMatakuliah(tampung2[1]);

        String[] tampung3 = dosen.split(" ");
        System.out.println(tampung3[0]);
        Dosen dos = new Dosen();
        dos.setId_dosen(tampung3[0]);
//        dos.setNama_dosen(tampung3[1]);


        Ruang rng = new Ruang();
        rng.setId_ruang(ruang);

        jadwal.setJam(jam);
        System.out.println(jam);

        jadwal.setKelas(kelas);
        System.out.println(kelas);

        jadwal.setIdDosen(dos);
        jadwal.setIdMakul(matkul);
        jadwal.setIdRuang(rng);

        try {
            JadwalKontrol jdwl;
            jdwl = JadwalKontrol.getKoneksi();
//            jdwl.tambahJadwal(jadwal);
            jdwl.cekJadwal(jadwal);

            comboDosen();
            comboMatakuliah();
            comboRuang();



        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(this, "Data Gagal Disimpan");
            Logger.getLogger(Master_Penjadwalan.class.getName()).log(Level.SEVERE, null, ex);
        }
//        lihatSemua();
        tampilSemua();
    }//GEN-LAST:event_simpanBtnActionPerformed

    private void updateBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updateBtnActionPerformed
        // TODO add your handling code here:
        Penjadwalan jadwal = new Penjadwalan();

        String hari = (String) HariCmbx.getSelectedItem();

        int k = kodeMakulCmbx.getSelectedIndex();
        String kode = kodeMakulCmbx.getItemAt(k).toString();
        int d = idDosenCmbx.getSelectedIndex();
        String dosen = idDosenCmbx.getItemAt(d).toString();
        int r = idRuangCmbx.getSelectedIndex();
        String ruang = (String) idRuangCmbx.getSelectedItem();
        System.out.println(ruang);
        String jam = (String) jamCmbx.getSelectedItem();
        String kelas = (String) kelasCmbx.getSelectedItem();

        jadwal.setHari(hari);

        String[] tampung2 = kode.split(" ");
        System.out.println(tampung2[0]);
        Matakuliah matkul = new Matakuliah();
        matkul.setIdMatakuliah(tampung2[0]);
//        matkul.setNamaMatakuliah(tampung2[1]);

        String[] tampung3 = dosen.split(" ");
        System.out.println(tampung3[0]);
        Dosen dos = new Dosen();
        dos.setId_dosen(tampung3[0]);
//        dos.setNama_dosen(tampung3[1]);

        Ruang rng = new Ruang();
        rng.setId_ruang(ruang);

        jadwal.setJam(jam);
        System.out.println(jam);

        jadwal.setKelas(kelas);
        System.out.println(kelas);

        jadwal.setIdDosen(dos);
        jadwal.setIdMakul(matkul);
        jadwal.setIdRuang(rng);


        int row = tabelJadwal.getSelectedRow();
        String hari1 = tabelJadwal.getValueAt(row, 0).toString();
        String jam1 = tabelJadwal.getValueAt(row, 1).toString();
        String kelas1 = tabelJadwal.getValueAt(row, 2).toString();
        String idmakul1 = tabelJadwal.getValueAt(row, 3).toString();
        String iddosen1 = tabelJadwal.getValueAt(row, 4).toString();
        String idruang1 = tabelJadwal.getValueAt(row, 5).toString();

        Penjadwalan jadwallama = new Penjadwalan();


        matkul = new Matakuliah();
        matkul.setIdMatakuliah(idmakul1);



        dos = new Dosen();
        dos.setId_dosen(iddosen1);
//        dos.setNama_dosen(tampung3[1]);

        rng = new Ruang();
        rng.setId_ruang(idruang1);

        jadwallama.setHari(hari1);
        jadwallama.setJam(jam1);
        jadwallama.setKelas(kelas1);
        jadwallama.setIdDosen(dos);
        jadwallama.setIdMakul(matkul);
        jadwallama.setIdRuang(rng);




        try {
            JadwalKontrol jdwl;
            jdwl = JadwalKontrol.getKoneksi();
            jdwl.updatePenjadwalan(jadwallama, jadwal);

            comboDosen();
            comboMatakuliah();
            comboRuang();

        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(this, "Data Gagal Disimpan");
            Logger.getLogger(Master_Penjadwalan.class.getName()).log(Level.SEVERE, null, ex);
        }
//        lihatSemua();
        tampilSemua();
    }//GEN-LAST:event_updateBtnActionPerformed

    private void hapusBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hapusBtnActionPerformed
        // TODO add your handling code here:
        Penjadwalan jadwal = new Penjadwalan();

        String hari = (String) HariCmbx.getSelectedItem();

        int k = kodeMakulCmbx.getSelectedIndex();
        String kode = kodeMakulCmbx.getItemAt(k).toString();
        int d = idDosenCmbx.getSelectedIndex();
        String dosen = idDosenCmbx.getItemAt(d).toString();
        int r = idRuangCmbx.getSelectedIndex();
        String ruang = (String) idRuangCmbx.getSelectedItem();
        System.out.println(ruang);
        String jam = (String) jamCmbx.getSelectedItem();
        String kelas = (String) kelasCmbx.getSelectedItem();

        jadwal.setHari(hari);

        String[] tampung2 = kode.split(" ");
        System.out.println(tampung2[0]);
        Matakuliah matkul = new Matakuliah();
        matkul.setIdMatakuliah(tampung2[0]);
//        matkul.setNamaMatakuliah(tampung2[1]);

        String[] tampung3 = dosen.split(" ");
        System.out.println(tampung3[0]);
        Dosen dos = new Dosen();
        dos.setId_dosen(tampung3[0]);
//        dos.setNama_dosen(tampung3[1]);

        Ruang rng = new Ruang();
        rng.setId_ruang(ruang);

        jadwal.setJam(jam);
        System.out.println(jam);

        jadwal.setKelas(kelas);
        System.out.println(kelas);

        jadwal.setIdDosen(dos);
        jadwal.setIdMakul(matkul);
        jadwal.setIdRuang(rng);

        try {
            JadwalKontrol jdwl;
            jdwl = JadwalKontrol.getKoneksi();
//            jdwl.tambahJadwal(jadwal);
            jdwl.hapusPrepared(jadwal);
            JOptionPane.showMessageDialog(this, "Data Berhasil Dihapus");

            comboDosen();
            comboMatakuliah();
            comboRuang();



        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(this, "Data Gagal Disimpan");
            Logger.getLogger(Master_Penjadwalan.class.getName()).log(Level.SEVERE, null, ex);
        }
//        lihatSemua();
        tampilSemua();
    }//GEN-LAST:event_hapusBtnActionPerformed

    private void tabelJadwalMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tabelJadwalMouseClicked
        // TODO add your handling code here:
        int row = tabelJadwal.getSelectedRow();
        String hari = tabelJadwal.getValueAt(row, 0).toString();
        String jam = tabelJadwal.getValueAt(row, 1).toString();
        String kelas = tabelJadwal.getValueAt(row, 2).toString();
        String idmakul = tabelJadwal.getValueAt(row, 3).toString();
        String iddosen = tabelJadwal.getValueAt(row, 4).toString();
        String idruang = tabelJadwal.getValueAt(row, 5).toString();

        HariCmbx.setSelectedItem(hari);
        jamCmbx.setSelectedItem(jam);
        kelasCmbx.setSelectedItem(kelas);
        kodeMakulCmbx.setSelectedItem(idmakul);
        idDosenCmbx.setSelectedItem(iddosen);
        idRuangCmbx.setSelectedItem(idruang);

//        idMatakuliahTxt.setText(kode);
//        namaMatakuliahTxt.setText(nama);
//        simpanMatakuliahBtn.setEnabled(true);
    }//GEN-LAST:event_tabelJadwalMouseClicked

    private void comboDosen() {
        try {
            List<Dosen> dosen = DosenKontrol.getKoneksi().getIdDosen();
            for (Dosen k : dosen) {
                String kodenya = k.getId_dosen();
//                idDosenCmbx.addItem(k.getId_dosen() + " " + k.getNama_dosen());
                idDosenCmbx.addItem(k.getId_dosen());
            }
        } catch (SQLException ex) {
            Logger.getLogger(Master_Penjadwalan.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void comboRuang() {
        try {
            List<Ruang> ruang = RuangKontrol.getKoneksi().lihatDataRuang();
            for (Ruang k : ruang) {
                String kodenya = k.getId_ruang();
                idRuangCmbx.addItem(k.getId_ruang());
            }
        } catch (SQLException ex) {
            Logger.getLogger(Master_Penjadwalan.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void comboMatakuliah() {
        try {
            List<Matakuliah> matkul = MakulKontrol.getKoneksi().lihatDataMakul();
            for (Matakuliah k : matkul) {
                String kodenya = k.getIdmatakuliah();
//                kodeMakulCmbx.addItem(k.getIdmatakuliah() + " " + k.getNamaMatakuliah());
                kodeMakulCmbx.addItem(k.getIdmatakuliah());
            }
        } catch (SQLException ex) {
            Logger.getLogger(Master_Penjadwalan.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

//    public void lihatSemua() {
//        HariCmbx.requestFocus();
//        try {
////            List<Penjadwalan> dos = JadwalKontrol.getKoneksi().lihatSeluruhJadwal();
//            List<Penjadwalan> dos = JadwalKontrol.getKoneksi().seluruhData();
//            PenjadwalanTabelModel table = new PenjadwalanTabelModel(dos);
//            tabelJadwal.setModel(table);
//        } catch (SQLException ex) {
//            Logger.getLogger(Master_Penjadwalan.class.getName()).log(Level.SEVERE, null, ex);
//        }
//    }
    private void tampilSemua() {
        HariCmbx.requestFocus();
        try {
            List<Penjadwalan> kat = JadwalKontrol.getKoneksi().lihatSeluruhJadwal();
            PenjadwalanTabelModel table = new PenjadwalanTabelModel(kat);
            tabelJadwal.setModel(table);
        } catch (SQLException ex) {
            Logger.getLogger(Master_Penjadwalan.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox HariCmbx;
    private javax.swing.JButton hapusBtn;
    private javax.swing.JComboBox idDosenCmbx;
    private javax.swing.JComboBox idRuangCmbx;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JComboBox jamCmbx;
    private javax.swing.JComboBox kelasCmbx;
    private javax.swing.JButton keluarBtn;
    private javax.swing.JComboBox kodeMakulCmbx;
    private javax.swing.JButton simpanBtn;
    private javax.swing.JTable tabelJadwal;
    private javax.swing.JButton updateBtn;
    // End of variables declaration//GEN-END:variables
}
